/*
 * Copyright (C) 2025 Tsingteng MicroSystem
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @file nfa_rw_t5t.h
 * @brief 读t5t卡相关API定义
 */

#ifndef __NFA_RW_T5T_H_
#define __NFA_RW_T5T_H_

#if IS_FEATURE_ON(NCI_FEATURE_RW_T5T)

#include<stdint.h>
#include "nfa_utils.h"

/**
 * @brief 读取T5T卡的单个块
 *
 * @param[in] block_number 块号
 * @param[out] p_rsp 返回的数据
 *
 * @note 当返回NCI_STATUS_OK时，p_rsp才有效，需要调用nfa_utils_free_rsp释放
 * @note 返回的数据第一个字节是状态码后续的才是block数据
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_read_single_block(uint16_t block_number, tNCI_RSP *p_rsp);

/**
 * @brief 发送Inventory指令
 *
 * @param[in] p_uid UID
 * @param[in] including_afi 是否包含AFI
 * @param[in] afi AFI
 *
 * @note 如果传入UID，按照UID[0]:MSB, ... UID[7]:LSB形式传入。
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_inventory(uint8_t* p_uid, bool including_afi, uint8_t afi);

/**
 * @brief 发送Select指令
 *
 * @param[in] p_uid UID
 *
 * @note UID按照[0]:MSB, ... UID[7]:LSB形式传入。
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_select(const uint8_t* p_uid);

/**
 * @brief 发送Stay Quiet指令
 *
 * @param[in] p_uid UID
 *
 * @note UID按照[0]:MSB, ... UID[7]:LSB形式传入。
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_stay_quiet(const uint8_t* p_uid);

/**
 * @brief 设置是否启用Address Mode
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
void nfa_rw_i93_set_addressing_mode(bool mode);

#if IS_FEATURE_ON(NCI_FEATURE_RW_NDEF)

/**
 * @brief 读取T5T卡的多个块
 *
 * @param[in] first_block_number 起始块号
 * @param[in] number_blocks 块数量
 * @param[out] p_rsp 返回的数据
 *
 * @note 当返回NCI_STATUS_OK时，p_rsp才有效，需要调用nfa_utils_free_rsp释放
 * @note 返回的数据第一个字节是状态码后续的才是block数据
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_read_multi_blocks(uint16_t first_block_number, uint16_t number_blocks, tNCI_RSP *p_rsp);

/**
 * @brief 写入单个块
 *
 * @param[in] block_number 块号
 * @param[in] p_data 块数据
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_write_single_block(uint32_t block_number,  uint8_t* p_data);

/**
 * @brief 发送Lock Block指令
 *
 * @param[in] block_number 块号
 *
 * @return 成功返回NCI_STATUS_OK，失败返回其他错误码
 */
tNCI_STATUS nfa_rw_i93_lock_block(uint32_t block_number);

#endif // IS_FEATURE_ON(NCI_FEATURE_RW_NDEF)

#endif // IS_FEATURE_ON(NCI_FEATURE_RW_T5T)

#endif// __NFA_RW_T5T_H_